import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'

export default defineConfig({
  base: '/',  // 只保留一个base配置
  plugins: [vue()],
  build: {    // 合并build配置
    outDir: '../dist',
    emptyOutDir: true,
    assetsInlineLimit: 4096,
    rollupOptions: {
      output: {
      manualChunks: {
          keymap: ['./src/utils/keyMap.js']
        }
      },
      input: './index.html'
    }
  },
  sserver: {
    host: '0.0.0.0',
    port: {
      start: 5173,
      end: 5183,
      strict: false
    },
    strictPort: false,
    proxy: {
      '/api': {
        target: 'https://www.mhbdkj.com:18998',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    },
    hmr: {
      port: 5174
    }
  },
  css: {
    postcss: {
      plugins: [
        require('tailwindcss')({ config: './tailwind.config.js' }),
        require('autoprefixer'),
        tailwindcss(),
        autoprefixer()
      ]
    }
  },
  resolve: {
    alias: {
      '@': '/src',
      '~': '/public'
    }
  }
})